<template>
	<view class="container">
		<view class="v1" >
			<uni-list v-for="item in noticeArr">
				<uni-list-chat :title="item.releaseTitle" avatar="/static/img/notice2.png" 
					:note="item.releaseContent" :time="item.releaseTime" :to="'/pages/detail/detail?id='+item.id"></uni-list-chat>
			</uni-list>
			<uni-list v-for="item in clientsArr">
				<uni-list-chat :title="item.title" avatar="/static/img/notice.png" 
					:note="item.clientname+'-'+item.housesname" :time="item.updateTime" :to="'/pages/working_platform/client/client_info?id='+item.id"></uni-list-chat>
			</uni-list>
		</view>
	</view>
</template>

<script setup>
import { onMounted, ref } from 'vue';
//定义一个数组存放公告数据
const noticeArr = ref([{
	releaseTitle:'春节放假通知',
	releaseContent:'春节假期安排如下:',
	releaseTime:'2025/01/25'
}
])
//定义加载通知的方法
const loadNotice = ()=>{
	uni.request({
		url:BASE_URL+'/api/crm/notice/select',
		data:noticeArr.value,
		success:(res)=>{
			if(res.data.code==2000){
				noticeArr.value=res.data.data;
			}else {
				uni.showToast({
				title:res.data.msg,
				icon:'error'
				});
			}
		}
	});	
}
// 定义一个数组存放用户数据
const clientsArr = ref([
	{
		title:'待跟踪订单',
		clientname:'小李',
		housesname:'西钓鱼台·御玺15-A_15',
		updateTime:'2025/01/25'
	}
]);
//定义加载客户信息的方法
const loadClients = ()=>{
	uni.request({
		url:BASE_URL+'/api/crm/customer/select',
		data:clientsArr.value,
		success:(res)=>{
			if(res.data.code==2000){
				clientsArr.value=res.data.data;
			}else {
				uni.showToast({
				title:res.data.msg,
				icon:'error'
				});
			}
		}
	});
}
//一打开页面就加载方法
onMounted(()=>{
	loadClients();
	loadNotice();
})
</script>

<style>
	.v1{
		width: 100%;
		height: 132rpx;
		background-color: #FFF;
	}
</style>
